<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            background-color: pink;
        }
    </style>
</head>

<body>
    <div id="test"></div>

    <!-- 引入核心库 -->
    <script type="text/javascript" src="./React-js/16.8/react.development.js"></script>
    <!-- 用于支持react操作DOM -->
    <script text="text/javascript" src="./React-js/16.8/react-dom.development.js"></script>
    <!-- 用于将jsx转换为js -->
    <script text="text/javascript" src="./React-js/16.8/babel.min.js"></script>

    <script type="text/babel">
        class Demo extends React.Component {
            /** React.createRef
             * 存放被ref标识的节点，但只能单独存一个
             */ 
            myRef = React.createRef()
            myRef2 = React.createRef()

             // 展示左侧输入框的数据
             showData = () => {
                console.log(this.myRef,this.myRef2);
            }
            render() {
                // 
                return (
                    <div>
                        <input ref={this.myRef} type="text" placeholder="点击按钮提示数据" />
                        <input ref={this.myRef2} type="text" placeholder="点击按钮提示数据" />
                        <button onClick={this.showData}>点击提示左侧的数据</button>&nbsp;
                    </div>
                )
            }
        }

        ReactDOM.render(<Demo />, document.querySelector('#test'))
    </script>
</body>

</html>